/**
 * Copyright (c) 2011-2016, James Zhan 詹波 (jfinal@126.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.candy.db.generator.utils;


import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * LogKit.
 */
public class LogKit {
    private static String LEVEL_DEBUG = "DEBUG";
    private static String LEVEL_INFO = "INFO";
    private static String LEVEL_WARN = "WARN";
    private static String LEVEL_ERROR = "ERROR";
    private static String LEVEL_FATAL = "FATAL";

    private static SimpleDateFormat format = new SimpleDateFormat();

    private static void print(String level,String message,Throwable t){
        System.out.println(String.format("[%s] %s %s %s",level,format.format(new Date()),message,t));
    }
    private static void print(String level,String message){
        System.out.println(String.format("[%s] %s %s",level,format.format(new Date()),message));
    }
	public static void debug(String message) {
        print(LEVEL_DEBUG,message);
	}
	
	public static void debug(String message, Throwable t) {
        print(LEVEL_DEBUG, message, t);
	}
	
	public static void info(String message) {
        print(LEVEL_INFO, message);
	}
	
	public static void info(String message, Throwable t) {
        print(LEVEL_INFO,message,t);
	}
	
	public static void warn(String message) {
        print(LEVEL_WARN,message);
	}
	
	public static void warn(String message, Throwable t) {
        print(LEVEL_WARN,message,t);
	}
	
	public static void error(String message) {
        print(LEVEL_ERROR,message);
	}
	
	public static void error(String message, Throwable t) {
        print(LEVEL_ERROR,message,t);
	}
	
	public static void fatal(String message) {
        print(LEVEL_FATAL,message);
	}
	
	public static void fatal(String message, Throwable t) {
        print(LEVEL_FATAL,message,t);
	}

}

